package com.homework.mergesort;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class MSBean implements WritableComparable<MSBean> {
    private int num;

    public MSBean() {
    }

    public MSBean(int num) {
        this.num = num;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    public int compareTo(MSBean o) {
        //升序排序
        if (num > o.getNum()) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(num);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.num = dataInput.readInt();
    }

    @Override
    public String toString() {
        return "" + num;
    }
}
